<!DOCTYPE html>
<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>基础知识</title>
	<link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css"" rel="stylesheet">
	<link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
	<link href="https://cdn.bootcdn.net/ajax/libs/animate.css/3.2.3/animate.css" rel="stylesheet">
	<link rel="stylesheet" href="../static/layui/css/layui.css" media="all">
	<link rel="stylesheet" type="text/css" href="../static/css/public.css" />
</head>
<body>
	<!--右边内容-->
	<div id="app" class="main">
		<div class="shadow">
			<div>
				<h3>常见居中方式</h3>
				<h4>行高+文本居中</h4>
				<pre>
	.lineHeight-img{
		width: 200px;
		height: 200px;
		line-height: 200px;//高度居中
		text-align: center;//水平居中
		border: 1px solid #000;
		font-size: 0px;
	}
	.lineHeight-img>img{
		display: inline-block;
		width: 20px;
		height:20px
		vertical-align: middle;//让盒子中间在水平线上
	}				
				</pre>
			</div>
			<div>
				<h4>table-cell居中</h4>
				<p>坑点 ： 有个坑点:如果内容超出父级,写超出部分隐藏无效。两个相同相连的 class 会变成正常的属性排版</p>
				<pre>
	.table_cell{
		display: table-cell;//可以让下面两种居中方式实现
		vertical-align: middle;//高度居中
		text-align: center;//水平居中
		width: 240px;
		height: 180px;
		border:1px solid #666;
	}
	.table_cell>div或者span都不影响				
				</pre>
			</div>
			<div>
				<h4>绝对定位+变换(相对绝对定位居中法)</h4>
				<pre>
	.position{
		background: yellow;
		width: 200px;
		height: 200px;
		overflow: hidden;
		border: 1px solid #000;
		position: relative;
	}	
	.position>div{
		position: absolute;
		width: 50px;
		left: 50%;
		top: 50%;
		transform: translate(-50%,-50%);
	}			
				</pre>
			</div>
			<div>
				<h4>弹性盒子</h4>
				<pre>
	.flex{
		display: flex;
		width: 200px;
		height: 200px;
		overflow: hidden;
		border: 1px solid #000;
		align-items: center;/*内容垂直居中*/
		justify-content: center;/*内容水平居中*/
	}	
				</pre>
			</div>
		</div>
	</div>
	<!--页面加载进度条-->
	<script src="https://cdn.bootcdn.net/ajax/libs/pace/0.5.0/pace.min.js"></script>
</body>

</html>